package gxb.test13;

import java.util.Scanner;

public class ExceptionTest {
    //1.定义一个类来监控体重是否超重，体重指数BMI=体重（kg）÷身高÷身高（m）
    // 中国成人居民BMI衡量标准是≤18.4为消瘦、18.5-23.9为正常
    // 24-27.9为超重、≥28为肥胖。体重超重需要提示多运动。
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Weight wg = new Weight();
        System.out.println("请输入体重(kg):");
        wg.setWeight(sc.nextDouble());
        System.out.println("请输入身高(m):");
        wg.setHeight(sc.nextDouble());
        double bmi=wg.getBmi(wg);
        if (bmi<=18.4)
            System.out.println("太瘦了，多吃肉");
        else if (bmi<=23.9 && bmi>=18.5)
            System.out.println("非常健康的身体哦");
        else if (bmi<=27.9 && bmi>=24) {
            System.out.println("体重超重，多运动");
        }
        else {
            System.out.println("肥胖人群，需要减肥了");
        }
        System.out.println(bmi);

    }
}
class Weight{
    private double height;
    private double weight;

    public void setHeight(double height) {
        this.height = height;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }
    public double getBmi(Weight wg){
        return weight/height/height;
    }
}
